﻿using Bentley.CifNET.GeometryModel;
using Bentley.CifNET.GeometryModel.SDK;
using BoxCulvert.entity;
using Checc.Culvert.LayingLine;
using Checc_CircularCulvert_Assemble.commons.overall;
using CheccCoverplateCulvertAssemble.Common.Total;
using CheccCoverplateCulvertAssemble.entity;
using CheccCoverplateCulvertAssemble.Entity;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CheccCoverplateCulvertAssemble.Common
{
    public class CommonData : MyNotifyPropertyChanged
    {
        private static CommonData m_instance;
        public static CommonData Instance
        {
            get
            {
                if (null == m_instance)
                {
                    m_instance = new CommonData();
                }
                return m_instance;
            }
            set { m_instance = value; }
        }
        public string WorkSpacePath => ConfigurationManager.GetVariable("Checc_CulvertCustomPath") == null? "C:\\Program Files\\CCCCLTD\\Highway BIM Solution\\ZJCulvert\\Resources\\" : ConfigurationManager.GetVariable("Checc_CulvertCustomPath");
        private double _culvertLenght;
        private CommomTotal _commomTotal = new CommomTotal();
        private CommonCoverPlateParameter commonCoverPlateParameter = new CommonCoverPlateParameter();
        private CommonCapStone _capStone = new CommonCapStone();
        private CommonEndWall _endWall = new CommonEndWall();
        private CommonAliformWall _aliformWall = new CommonAliformWall();
        private CommonConicalSlope _conicalSlop = new CommonConicalSlope();
        //private CommonShaft _shaft = new CommonShaft();
        private bool _isExchangFill;
        //private List<CommonExchangFill> _exchangFills = new List<CommonExchangFill>();
        private CommonDigSide _digSide = new CommonDigSide();

        private CommonCulvertLengthSet _commonCulvertLengthSet = new CommonCulvertLengthSet();   

        private CommonDropWell _dropWell = new CommonDropWell();
        private CommonHeadFall _headWell = new CommonHeadFall();
        private CommonRhone _rhone = new CommonRhone();

        private SideDitchFallWell _sideDitchFallWellLeft = new SideDitchFallWell();
        private SideDitchFallWell _sideDitchFallWellRight = new SideDitchFallWell();

        private BasicConstructor _basicConstructor = new BasicConstructor();
        

        /*************************************进出口急流槽*************************************************/
        private CommonChuteInBase _commonChuteIn = new CommonChuteInBase();
        private CommonChuteOutBase _commonChuteOut = new CommonChuteOutBase();

        /*************************************通道*************************************************/
        private CulvertAisleEntity _culvertAisleEntity = new CulvertAisleEntity();

        /// <summary>
        /// 涵洞创建的所有元素集
        /// </summary>
        public List<string> ElementIds { get; set; } = new List<string>();

        /// <summary>
        /// 涵洞线及标注
        /// </summary>
        public List<string> LayLineIds { get; set; } = new List<string>();

        /// <summary>
        /// 换填
        /// </summary>
        public Dictionary<string, ReplaceMentEntity> replaceMent  { get; set;}
        /// <summary>
        /// 涵长分段
        /// </summary>
        public List<double> culvertLenLists { get; set; }

        /// <summary>
        /// 进口边坡交点
        /// </summary>
        public CulvertPointInfo EntrancePointInfo { get; set; }
        /// <summary>
        /// 出口边坡交点
        /// </summary>
        public CulvertPointInfo ExitPointInfo { get; set; }
        /// <summary>
        /// 涵洞布置线
        /// </summary>
        [JsonIgnore]
        public Alignment CulverIntersectingLine { get; set; }

        /// <summary>
        /// 进口涵身角度
        /// </summary>
        public Angle EntranceAngle { get; set; }
        /// <summary>
        /// 出口涵身角度
        /// </summary>
        public Angle ExitAngle { get; set; }

        /// <summary>
        /// 虚拟涵长
        /// </summary>
        public double VirtualCulvertLength { get; set; }
        /// <summary>
        /// 真实涵长
        /// </summary>
        public double CulvertLength { get; set; }

        /// <summary>
        /// 进水口内嵌水平值
        /// </summary>
        public double intoLength { get; set; }
        /// <summary>
        /// 出水口（内嵌、外延）水平值
        /// </summary>
        public double outLength { get; set; }
        /// <summary>
        /// 涵洞放置点矩阵
        /// </summary>
        public DMatrix3d placePtDmatrix3d { get; set; }
        /// <summary>
        /// 涵洞行车方向左侧放置点
        /// </summary>
        public DPoint3d culvertPlacePoint3d { get; set; }
        /// <summary>
        /// Civil路线
        /// </summary>
        [JsonIgnore]
        public LinearEntity2dInPlan linearEntity2DInPlan { get; set; }

        /// <summary>
        /// 三维临时生成的洞口元素
        /// </summary>
        [JsonIgnore]
        public List<Element> TempElements { get; set; } = new List<Element>();

        /// <summary>
        /// 总体信息
        /// </summary>
        public CommomTotal CommomTotal
        {
            get
            {
                return _commomTotal;
            }
            set
            {
                if (value == _commomTotal)
                    return;
                NotifyPropertyChanged(() => _commomTotal);
                _commomTotal = value;
            }
        }

        /// <summary>
        /// 涵长分段信息
        /// </summary>
        public CommonCulvertLengthSet CommonCulvertLengthSet
        {
            get
            {
                return _commonCulvertLengthSet;
            }
            set
            {
                if (value == _commonCulvertLengthSet)
                    return;
                NotifyPropertyChanged(() => _commonCulvertLengthSet);
                _commonCulvertLengthSet = value;
            }
        }

        /// <summary>
        /// 涵身信息
        /// </summary>
        public BasicConstructor basicConstructor
        {
            get
            {
                return _basicConstructor;
            }
            set
            {
                if (value == _basicConstructor)
                    return;
                NotifyPropertyChanged(() => _basicConstructor);
                _basicConstructor = value;
            }
        }

        /// <summary>
        /// 盖板信息
        /// </summary>
        public CommonCoverPlateParameter CoverPlateParameter
        {
            get
            {
                return commonCoverPlateParameter;
            }
            set
            {
                if (value == commonCoverPlateParameter)
                    return;
                NotifyPropertyChanged(() => commonCoverPlateParameter);
                commonCoverPlateParameter = value;
            }
        }
        /// <summary>
        /// 帽石
        /// </summary>
        public CommonCapStone CapStone
        {
            get
            {
                return _capStone;
            }
            set
            {
                if (value == _capStone)
                    return;
                NotifyPropertyChanged(() => _capStone);
                _capStone = value;
            }
        }


        /// <summary>
        /// 端墙
        /// </summary>
        public CommonEndWall EndWall
        {
            get
            {
                return _endWall;
            }
            set
            {
                if (value == _endWall)
                    return;
                NotifyPropertyChanged(() => _endWall);
                _endWall = value;
            }
        }

        /// <summary>
        /// 八字墙
        /// </summary>
        public CommonAliformWall AliformWall
        {
            get
            {
                return _aliformWall;
            }
            set
            {
                if (value == _aliformWall)
                    return;
                NotifyPropertyChanged(() => _aliformWall);
                _aliformWall = value;
            }
        }

        /// <summary>
        /// 锥坡
        /// </summary>
        public CommonConicalSlope ConicalSlope
        {
            get
            {
                return _conicalSlop;
            }
            set
            {
                if (value == _conicalSlop)
                    return;
                _conicalSlop = value;
                NotifyPropertyChanged(() => ConicalSlope);
            }
        }

        /// <summary>
        /// 跌水井
        /// </summary>
        public CommonDropWell DropWell
        {
            get
            {
                return _dropWell;
            }
            set
            {
                if (value == _dropWell)
                    return;
                _dropWell = value;
                NotifyPropertyChanged(() => DropWell);
            }
        }
        /// <summary>
        /// 跌水
        /// </summary>
        public CommonHeadFall HeadFall
        {
            get
            {
                return _headWell;
            }
            set
            {
                if (value == _headWell)
                    return;
                _headWell = value;
                NotifyPropertyChanged(() => HeadFall);
            }
        }
        /// <summary>
        /// 排水槽
        /// </summary>
        public CommonRhone Rhone
        {
            get
            {
                return _rhone;
            }
            set
            {
                if (value == _rhone)
                    return;
                _rhone = value;
                NotifyPropertyChanged(() => Rhone);
            }
        }

        public SideDitchFallWell SideDitchFallWellLeft
        {
            get
            {
                return _sideDitchFallWellLeft;
            }

            set
            {
                if (value == _sideDitchFallWellLeft) return;
                _sideDitchFallWellLeft = value;
                NotifyPropertyChanged(() => SideDitchFallWellLeft);
            }
        }
        public SideDitchFallWell SideDitchFallWellRight
        {
            get
            {
                return _sideDitchFallWellRight;
            }

            set
            {
                if (value == _sideDitchFallWellRight) return;
                _sideDitchFallWellRight = value;
                NotifyPropertyChanged(() => SideDitchFallWellRight);
            }
        }


        /// <summary>
        /// 进口急流槽
        /// </summary>
        public CommonChuteInBase CommonChuteIn
        {
            get
            {
                return _commonChuteIn;
            }
            set
            {
                if (value == _commonChuteIn)
                    return;
                NotifyPropertyChanged(() => CommonChuteIn);
                _commonChuteIn = value;
            }
        }

        /// <summary>
        /// 进口急流槽
        /// </summary>
        public CommonChuteOutBase CommonChuteOut
        {
            get
            {
                return _commonChuteOut;
            }
            set
            {
                if (value == _commonChuteOut)
                    return;
                NotifyPropertyChanged(() => CommonChuteOut);
                _commonChuteOut = value;
            }
        }

        public CulvertAisleEntity CulvertAisleEntity
        {
            get
            {
                return _culvertAisleEntity;
            }

            set
            {
                if (value == _culvertAisleEntity) return;
                NotifyPropertyChanged(() => CulvertAisleEntity);
                _culvertAisleEntity = value;
            }
        }

    }

}
